package com.frx.sort.insertsort;

import java.util.Arrays;

/**
 * Created with IDEA
 *
 * @author: xrf
 * @Date: 2019/10/25
 * @Time: 17:42
 */
public class TestTwo {

    public static void main(String[] args){

        int[] arr = {6,5,4,1,3,2,7,0};
        sort(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void sort(int[] arr){

        for (int i=1;i<arr.length;i++){
            int val = arr[i];
            int j=i-1;
            for (;j>=0;j--){
                if (arr[j] > val){
                    arr[j+1] = arr[j];
                } else {
                    break;
                }
            }
            arr[j+1] = val;
        }
    }

}
